<template>
  <el-form class="addGiftNews">
    <el-dialog
      :visible.sync="isVisible"
      title="奖励信息发送"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :modal-append-to-body="false"
      @close="closeDialog"
      width="550px"
      center
    >
      <el-form :model="formdata">
        <p class="tips">久等啦~您的奖励已经发放，请注意查收您的奖励！</p>
        <el-form-item label="礼包1：">
          <el-input
            v-model="formdata.gift1"
            placeholder="请填写奖励礼包码"
            type="text"
            maxlength="50"
            show-word-limit
          ></el-input>
          <el-input
            v-model="formdata.gift1remark"
            placeholder="可附加简短礼包说明"
            style="margin-left:20px"
            type="text"
            maxlength="50"
            show-word-limit
          ></el-input>
        </el-form-item>
        <el-form-item label="礼包2：">
          <el-input
            v-model="formdata.gift2"
            placeholder="请填写奖励礼包码"
            type="text"
            maxlength="50"
            show-word-limit
          ></el-input>
          <el-input
            v-model="formdata.gift2remark"
            placeholder="可附加简短礼包说明"
            style="margin-left:20px"
            type="text"
            maxlength="50"
            show-word-limit
          ></el-input>
        </el-form-item>
        <el-form-item label="礼包3：">
          <el-input
            v-model="formdata.gift3"
            placeholder="请填写奖励礼包码"
            type="text"
            maxlength="50"
            show-word-limit
          ></el-input>
          <el-input
            v-model="formdata.gift3remark"
            placeholder="可附加简短礼包说明"
            style="margin-left:20px"
            type="text"
            maxlength="50"
            show-word-limit
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm('formdata')">确 定</el-button>
      </div>
    </el-dialog>
  </el-form>
</template>
<script>
export default {
  inject: ["reload"],
  name: "addGiftNews",
  data() {
    return {
      isVisible: this.isShow,
      formdata: {
        gift1: "",
        gift1remark: "",
        gift2: "",
        gift2remark: "",
        gift3: "",
        gift3remark: ""
      },
      rules: {
        gift1: [{ required: true, message: "请输入礼包码", trigger: "blur" }]
      }
    };
  },
  props: {
    isShow: Boolean,
    dialogRow: Object
  },
  methods: {
    closeDialog() {
      this.$emit("closeDialog");
    },
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          //   const para = Object.assign({}, this.formdata);
          var str =
            "久等啦~您的奖励已经发放，请注意查收您的奖励！n礼包1：" +
            this.formdata.gift1;
          var str2 = "礼包2：";
          var str3 = "礼包3：";
          //   str = str.replace(/n/g, "\n");
          if (this.formdata.gift1remark != "") {
            str = str + "," + this.gift1remark + "n";
          }
          if(this.formdata.gift2)
          //   addservice(para)
          //     .then(res => {
          //       this.$message({
          //         message: res.msg,
          //         type: "success"
          //       });
          //       setTimeout(() => {
          //         this.reload();
          //       }, 20);
          //     })
          //     .catch(error => {});
          this.isVisible = false;
        }
      });
    }
  }
};
</script>
<style lang="scss">
.addGiftNews {
  .tips {
    font-size: 13px;
    text-align: center;
    margin-bottom: 30px;
  }
  .el-input {
    width: 203px;
  }
  .el-dialog--center .el-dialog__body {
    padding: 25px 25px 50px;
    margin-bottom: 10px;
  }
  .el-dialog--center .el-form-item__content {
    margin-bottom: 10px;
  }
}
</style>